#include<bits/stdc++.h>
//fangweibiaoqian
#define int long long
using namespace std;
const int N=1e5+5;
int n,r[N],maxr=-INT_MAX,minr=INT_MAX,mp[N];
signed main(){
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
		cin>>r[i];
		mp[r[i]]++;
		minr=min(minr,r[i]);
		maxr=max(maxr,r[i]);
	}
	int ans=0;
	for(int i=minr;i<=maxr;i++){
		if(mp[i]>=2) ans+=(mp[i]-1);
	}
	cout<<ans;
    return 0;
}
